<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	request.setCharacterEncoding("UTF-8");
	String cp = request.getContextPath(); 
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="<%=cp%>/data/css/common.css" rel="stylesheet" type="text/css" />
<link href="<%=cp%>/flight/css/style.css" rel="stylesheet" type="text/css" />
<link href="<%=cp%>/flight/css/common_1.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=cp%>/data/js/jquery-1.8.2.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />    
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>    
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script type="text/javascript">
$(function() {        
	
	if("${userId}" == null || "${userId}" == ""){
		location.href = "<%=cp%>/member/login.action";
		return
	}
	
	$("#datepicker").datepicker();
	
/* 	document.reserForm.inwon.value = "${routeNo}"; */
	
	// naraNo 조회
	$("#naraNo").change(function(){		
		document.getElementById("endPlace1").setAttribute("style","display:none");
		document.getElementById("endPlace2").setAttribute("style","display:none");
		document.getElementById("endPlace3").setAttribute("style","display:none");
		document.getElementById("endPlace4").setAttribute("style","display:none");	 
		
		for (var i=1; i<=$("#naraNo").val(); i++){
			
			if(i == $("#naraNo").val()){
				document.getElementById("endPlace"+i).style.display = "block";
			}
		}
	});
		
		


/* 	$("input[name=startDate]").focusout(function(){
		checkValue();
	}); */
});

//사용자가 여행자
function PtrChk(obj) {

    //선택
    if (obj.checked) {

        $("input[name='t_korName_1']").eq(0).val($("#korName").val());        //이름
        $("input[name='t_engName_1']").eq(0).val($("#engName").val());        //영이름
        $("input[name='t_birth_1']").eq(0).val($("#birth").val());        //이름
    }else{
    	$("input[name='t_korName_1']").eq(0).val("");
    	$("input[name='t_engName_1']").eq(0).val("");
    	$("input[name='t_birth_1']").eq(0).val("");
    }
       
}

//여행자 인원 수에 맞게
function TotNoChk(v){
	
	document.getElementById("divAdd2").setAttribute("style","display:none");
	document.getElementById("divAdd3").setAttribute("style","display:none");
	document.getElementById("divAdd4").setAttribute("style","display:none");
	document.getElementById("divAdd5").setAttribute("style","display:none");
	document.getElementById("divAdd6").setAttribute("style","display:none");
	
	//다른폼에 inwon값 셋팅
	var inwon = document.scheduleForm.inwon.value;
	document.reserForm.inwon.value = inwon;
	//memo
	var memo = document.scheduleForm.memo.value;
	document.reserForm.memo.value = memo;
	
	for (var i=2; i<=v; i++){
		document.getElementById("divAdd"+i).style.display = "block";

	}
}


function checkValue(){
	f = document.scheduleForm;
	
	if(f.startPlace.value == null || f.startPlace.value == ""){
		alert("출발지를 선택해주세요");
		return;
	}
/* 	if($("input[name='endPlace']").val() == null || $("input[name='endPlace']").val() == ""){
		alert("도착지를 선택해주세요");
		return;
	} */

}

//아작스로처리..
<%-- function checkFlight(){
	
 	f = document.scheduleForm;
	f.action = "<%=cp%>/flight/checkSchedule.action";
	f.submit(); 
	
} --%>

$(function(){
	
	$("#checkIt").click(function(){
		
		var params = "startPlace=" +$("#startPlace").val()+ 
					  "&endPlace=" +$("select[name='endPlace'] option:selected").val()+
					  "&startDate=" +$("input[name='startDate']").val();

 		$.ajax({
			type:"post",
			url:"<%=cp%>/flight/checkSchedule.action",
			data:params,
			async:false, 
			success:function(args){
				//alert($("select[name='endPlace'] option:selected").val());
				$("#routeNo").val(args);
				
				if($("#routeNo").val() == 0){
					alert("예매가 불가능합니다 \n다른 일정을 선택해주세요!");
				}else if($("#routeNo").val() != 0){
					alert("조회되었습니다. \n예매가 가능합니다. ");
				}
				document.reserForm.inwon.value = $("#routeNo").val;
				
			},
			beforeSend: checkValue,
			error: function(e){
				alert(e.responseText);
			}
		});

		
	});
});

<%-- function chekFlight(){
	
	checkValue();
	
	var params = "startPlace=" +$("#startPlace").val()+ 
	  "&endPlace=" +$("select[name='endPlace'] option:selected").val()+
	  "&startDate=" +$("input[name='startDate']").val();
	
	document.location.href = "<%=cp%>/flight/checkSchedule.action?"+params;

} --%>

function chkReservation(value){
	f = document.reserForm;
	
	if(document.scheduleForm.startDate.value == "" || document.scheduleForm.startDate.value == null){
		alert("출국 일자를 선택해주세요");
		return
	}
	
	if(value == "reservation"){
		f.action = "<%=cp%>/reservation/created.action";
		f.submit();
	}
}

</script>
</head>
<body>
<div id="container">
	<div id="content">
	 
	  <!-- 단체항공권 문의 -->
	  <div class="mg_t_20"><img src='http://ke.kaltour.com/airimg/images/common/h_groupAir.gif' alt="단체항공권 문의" /></div>
	  <div><img src='<%=cp%>/flight/image/img_groupAir.gif' alt="" /></div>
	  <!--// 단체항공권 문의 -->
	  <form name="scheduleForm" method="post">
	  <!-- 항공일정 -->
	  <div id="passenger">
		  <div class="titImg"><img src='http://ke.kaltour.com/airimg/images/common/h_airSchd.gif' alt="항공일정" /></div>
			 <div class="table" >
			  <table class="w100">
				<tr>
				  <td class="data1">출발도시</td>
				  <td class="data2d">
					<!--------------------------------------------------------------------------->
						<select name="startPlace" id="startPlace" class="select1 v_m" style="width:96px;">
						    <option value="인천" selected="selected">인천</option>
						    <option value="서울">서울</option>
						    <option value="김포">김포</option>
						    <option value="부산">부산</option>
						    <option value="광주">광주</option>
						    <option value="대구">대구</option>
						    <option value="제주">제주</option>
						    <option value="속초">속초</option>
						    <option value="목포">목포</option>
						</select>
                     <!--------------------------------------------------------------------------->				  				  
				  </td>
				  <td class="data1">도착도시</td>
				  <td class="data3d">
				  <!----------------------------------------------------------------------------->
				  	<select name="naraNo" id="naraNo" class="select1 v_m" style="width:96px;">
				  		<option value="" selected="selected">선택해주세요</option>
				  		<option value="1">유럽</option>
				  		<option value="2">일본/중국</option>
				  		<option value="3">미주</option>
				  		<option value="4">동남아</option>
				  	</select>
				  	<select name="endPlace" id="endPlace1" class="select1 v_m" style="width:96px; display:none;">
				  		<option value="프랑스">프랑스</option>
				  		<option value="체코">체코</option>
				  	</select>
				  	<select name="endPlace" id="endPlace2" class="select1 v_m" style="width:96px; display:none;">
				  		<option value="도쿄">도쿄</option>
				  		<option value="북경">북경</option>
				  	</select>
				  	<select name="endPlace" id="endPlace3" class="select1 v_m" style="width:96px; display:none;">
				  		<option value="괌">괌</option>
				  		<option value="하와이">하와이</option>
				  	</select>
				  	<select name="endPlace" id="endPlace4" class="select1 v_m" style="width:96px; display:none;">
				  		<option value="태국">태국</option>
				  		<option value="베트남">베트남</option>
				  	</select>
				  <!-----------------------------------------------------------------------------> 
				  </td>
				</tr>
				<tr>
					<td class="data1">출국일자</td>
					<td class="data2d">
					<input type="text" name="startDate" style="width:72px;" class="ipbox" id="datepicker" value="" style="cursor:pointer" readonly/>
					<img src="http://ke.kaltour.com/airimg/images/main/btn_city.gif" value="항공일정 확인하기" id="checkIt" />
					<input type="hidden" id="routeNo"/>
					</td>
					
						<td class="data1">탑승인원</td>
						<td class="data3d">	
						<div class="perNum">
						<ul>
							<li>
								<!--------------------------------------------------------------------------->
								<select name="inwon" id="inwon" class="select1 v_m" style="width:40px;" onchange="TotNoChk(this.value);">
								    <option value="1">1명</option>
								    <option value="2">2명</option>
								    <option value="3">3명</option>
								    <option value="4">4명</option>
								    <option value="5">5명</option>
								    <option value="6">6명</option>
								</select>
								<!--------------------------------------------------------------------------->
							  </li>
				        </ul>
					  </div>
						</td>					
				</tr>
				<tr>
                  <td class="data1a">요청사항</td>
				  <td colspan="3" class="data2a"><textarea name="memo" class="textareaBox2"></textarea></td>
			    </tr>
			  </table>
			</div>
      </div>
  </form>
	  <!--// 항공일정 -->
  <form name="reserForm">
  <input type="hidden" name="gubunNo" id="gubunNo" value="${routeNo}"/>
  <input type="hidden" name="gubun" id="gubun" value="2"/>
  <input type="hidden" name="userId" value="${userId}"/>
  <input type="hidden" name="inwon" value="1"/>
  <input type="hidden" name="memo" value=""/>
  <input type="hidden" name="mode" value="reservation"/>
	  <!-- 예약자 정보 -->
	  <div id="passenger">
	  <div class="titImg"><img src='http://ke.kaltour.com/airimg/images/common/h_air_data2.gif' alt="예약자 정보" /></div>
	    <div class="table">
		  <table>
			<tr>
			  <td class="data1">예약자</td>
			  <td class="data2">${user.korName}<input type="hidden" id="korName" value="${user.korName}"/></td>
			  <td class="data1">영문이름</td>
              <td class="data3">${user.engName}<input type="hidden" id="engName" value="${user.engName}"/></td>
			</tr>
			<tr>
				<td class="data1">휴대폰</td>
				<td class="data2">
					<input type="text" name="phone" style="width:200px; ime-mode:disabled;" class="ipbox" value="${user.phone}" />		
				</td>
				<td class="data1">생년월일</td>
				<td class="data3">
					<input type="text" id="birth" name="birth" style="width:200px; ime-mode:disabled;" class="ipbox" value="${user.birth}"/>              			
				</td>
			</tr>
		  </table>
	    </div>
	  </div>
	  <!--// 예약자 정보 -->
	  
	  <!-- 탑승자 정보 -->
	  <div id="passenger">
	  <div class="titImg"><img src='http://ke.kaltour.com/airimg/images/common/h_air_data3.gif' alt="탑승자 정보" /><span class="t1">
	  	<input name="ptrchk" class="type_checkbox" id="ptrchk" onclick="PtrChk(this);" type="checkbox" value="Y"/>&nbsp;예약자와 탑승자 정보동일</span></div>	  	
	    <div class="table">
		  <table id ="tbpass">
			<tr style="display:block;" id="divAdd">
			  <th class="data4">선택</th>
			  <th class="data5">한글이름</th>
			  <th class="data5">영문이름</th>
			  <th class="data6">구분</th>
              <th class="data7">생년월일</th>
			</tr>		
			<tr style="display:block;" id="divAdd1">
				<td class="data10">
					<input type="checkbox" name="chkPass" class="inputT">
				</td>
				<td class="data10">
					<input type="text" name="t_korName_1" id="t_korName_1" onkeypress="checkAlpha2()" class="ipbox" value="">
				</td>
				<td class="data10">
					<input type="text" name="t_engName_1" id="t_engName_1" onkeypress="checkAlpha2()" style="ime-mode:disabled; text-transform: uppercase;" class="ipbox" value="">
				</td>
				<td class="data10">				
					<input type="hidden" name="paxType"/>		
					<select name="paxTitle" cssClass="select1">
						<option value="MR" selected>성인남자</option>			
						<option value="MS">성인여자</option>
						<option value="MSTR">소아남자</option>
						<option value="MISS">소아여자</option>
						<option value="MSTR">유아남자</option>
						<option value="MISS">유아여자</option>																	
					</select>			
				</td>
				<td class="data10">
					<input type="text" name="t_birth_1" id="t_birth_1"onkeypress="makeDateFormat()" maxlength="10" style="width:70px;" class="ipbox">
				</td>
			</tr>
			
			<!-- 2 -->
			<tr style="display:none;" id="divAdd2">
				<td class="data10">
					<input type="checkbox" name="chkPass" class="inputT">
				</td>
				<td class="data10">
					<input type="text" name="t_korName_2" onkeypress="checkAlpha2()" class="ipbox" value="">
				</td>
				<td class="data10">
					<input type="text" name="t_engName_2" onkeypress="checkAlpha2()" style="ime-mode:disabled; text-transform: uppercase;" class="ipbox" value="">
				</td>
				<td class="data10">				
					<input type="hidden" name="paxType"/>		
					<select name="paxTitle" cssClass="select1">
						<option value="MR" selected>성인남자</option>			
						<option value="MS">성인여자</option>
						<option value="MSTR">소아남자</option>
						<option value="MISS">소아여자</option>
						<option value="MSTR">유아남자</option>
						<option value="MISS">유아여자</option>																	
					</select>			
				</td>
				<td class="data10">
					<input type="text" name="t_birth_2" onkeypress="makeDateFormat()" maxlength="10" style="width:70px;" class="ipbox">
				</td>
			</tr>
			<!-- 2 끝 -->
			<!-- 3 -->
			<tr style="display:none;" id="divAdd3">
				<td class="data10">
					<input type="checkbox" name="chkPass" class="inputT">
				</td>
				<td class="data10">
					<input type="text" name="t_korName_3" onkeypress="checkAlpha2()" class="ipbox" value="">
				</td>
				<td class="data10">
					<input type="text" name="t_engName_3" onkeypress="checkAlpha2()" style="ime-mode:disabled; text-transform: uppercase;" class="ipbox" value="">
				</td>
				<td class="data10">				
					<input type="hidden" name="paxType"/>		
					<select name="paxTitle" cssClass="select1">
						<option value="MR" selected>성인남자</option>			
						<option value="MS">성인여자</option>
						<option value="MSTR">소아남자</option>
						<option value="MISS">소아여자</option>
						<option value="MSTR">유아남자</option>
						<option value="MISS">유아여자</option>																	
					</select>			
				</td>
				<td class="data10">
					<input type="text" name="t_birth_3" onkeypress="makeDateFormat()" maxlength="10" style="width:70px;" class="ipbox">
				</td>
			</tr>
			<!-- 3 끝 -->
			<!-- 4 -->
			<tr style="display:none;" id="divAdd4">
				<td class="data10">
					<input type="checkbox" name="chkPass" class="inputT">
				</td>
				<td class="data10">
					<input type="text" name="t_korName_4" onkeypress="checkAlpha2()" class="ipbox" value="">
				</td>
				<td class="data10">
					<input type="text" name="t_engName_4" onkeypress="checkAlpha2()" style="ime-mode:disabled; text-transform: uppercase;" class="ipbox" value="">
				</td>
				<td class="data10">				
					<input type="hidden" name="paxType"/>		
					<select name="paxTitle" cssClass="select1">
						<option value="MR" selected>성인남자</option>			
						<option value="MS">성인여자</option>
						<option value="MSTR">소아남자</option>
						<option value="MISS">소아여자</option>
						<option value="MSTR">유아남자</option>
						<option value="MISS">유아여자</option>																	
					</select>			
				</td>
				<td class="data10">
					<input type="text" name="t_birth_4" onkeypress="makeDateFormat()" maxlength="10" style="width:70px;" class="ipbox">
				</td>
			</tr>
			<!-- 4 끝 -->
			<!-- 5 -->
			<tr style="display:none;" id="divAdd5">
				<td class="data10">
					<input type="checkbox" name="chkPass" class="inputT">
				</td>
				<td class="data10">
					<input type="text" name="t_korName_5" onkeypress="checkAlpha2()" class="ipbox" value="">
				</td>
				<td class="data10">
					<input type="text" name="t_engName_5" onkeypress="checkAlpha2()" style="ime-mode:disabled; text-transform: uppercase;" class="ipbox" value="">
				</td>
				<td class="data10">				
					<input type="hidden" name="paxType"/>		
					<select name="paxTitle" cssClass="select1">
						<option value="MR" selected>성인남자</option>			
						<option value="MS">성인여자</option>
						<option value="MSTR">소아남자</option>
						<option value="MISS">소아여자</option>
						<option value="MSTR">유아남자</option>
						<option value="MISS">유아여자</option>																	
					</select>			
				</td>
				<td class="data10">
					<input type="text" name="t_birth_5" onkeypress="makeDateFormat()" maxlength="10" style="width:70px;" class="ipbox">
				</td>
			</tr>
			<!-- 5 끝 -->
			<!-- 6 -->
			<tr style="display:none;" id="divAdd6">
				<td class="data10">
					<input type="checkbox" name="chkPass" class="inputT">
				</td>
				<td class="data10">
					<input type="text" name="t_korName_6" onkeypress="checkAlpha2()" class="ipbox" value="">
				</td>
				<td class="data10">
					<input type="text" name="t_engName_6" onkeypress="checkAlpha2()" style="ime-mode:disabled; text-transform: uppercase;" class="ipbox" value="">
				</td>
				<td class="data10">				
					<input type="hidden" name="paxType"/>		
					<select name="paxTitle" cssClass="select1">
						<option value="MR" selected>성인남자</option>			
						<option value="MS">성인여자</option>
						<option value="MSTR">소아남자</option>
						<option value="MISS">소아여자</option>
						<option value="MSTR">유아남자</option>
						<option value="MISS">유아여자</option>																	
					</select>			
				</td>
				<td class="data10">
					<input type="text" name="t_engName_6" onkeypress="makeDateFormat()" maxlength="10" style="width:70px;" class="ipbox">
				</td>
			</tr>
			<!-- 6끝 -->
			
			<!-- -----------------------------------------------  끝 -------------------------------------- -->		
		  </table>
		  </div> 
	  </div>
	  <!--// 탑승자 정보 -->
	 <br/>
	 <div align="right">
     		<img style="cursor: pointer;" onclick="chkReservation('cancel');" alt="취소" src="<%=cp%>/reservation/image/icon_cancel.jpg"/>
     		<img style="cursor: pointer;" onclick="chkReservation('reservation');" alt="예약하기" src="<%=cp%>/reservation/image/icon_reservation.jpg" />
     	</div>
	</form>
  </div>
  
</div>  
  

</body>
</html>